package com.redribbon.droidnoise;

import java.io.IOException;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.util.Log;


public class StreamClient extends Service {

	private MessageParser audioParser;
	
	@Override
	public void onCreate() {
		
		audioParser = new MessageParser(this, mCallbacks); 
		Thread thread = new Thread(audioParser);
		thread.start();
	}
	
    /**
     * This is a list of callbacks that have been registered with the
     * service.  Note that this is package scoped (instead of private) so
     * that it can be accessed more efficiently from inner classes.
     */
    final RemoteCallbackList<StreamClientServiceCallback> mCallbacks = new RemoteCallbackList<StreamClientServiceCallback>();
	    	
	@Override
	public IBinder onBind(Intent intent) {
		return mBinder;
	}

    /**
     * The StreamServerService is defined through IDL
     */
    private final StreamClientService.Stub mBinder = new StreamClientService.Stub() {
        public void registerCallback(StreamClientServiceCallback cb) {
            if (cb != null) mCallbacks.register(cb);
        }
        public void unregisterCallback(StreamClientServiceCallback cb) {
            if (cb != null) mCallbacks.unregister(cb);
        }
    };
    
}
